package com.ruoyi.web.controller;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class TestController extends BaseController {
    @Autowired
    private ISysUserService userService;
    @Autowired
    private UserDetailsService userDetailsService;

    @GetMapping("/getUser/{id}")
    public SysUser test(@PathVariable("id") Long userId){
        SysUser user = userService.getById(userId);
        return user;
    }

    @GetMapping("getUser2/{id}")
    public AjaxResult test2(@PathVariable("id") Long userId){
        SysUser user = userService.getById(userId);
        return AjaxResult.success(user);
    }

    @GetMapping("/testPage")
    public TableDataInfo testPage(){
        startPage();
        List<SysUser> list = userService.list();
        return getDataTable(list);
    }

    @GetMapping("/getInfo2")
    public AjaxResult getUserInfo(Long uerId){
        System.out.println(userDetailsService);
        return AjaxResult.success(userDetailsService);
    }
}
